
#ifndef CHARGE_CHECK_H
#define CHARGE_CHECK_H


#include "stdint.h"
#include "arm_math.h"

#define  BAT_CHARGE_VOL_MIN    12.5f
#define  BAT_CHARGE_VOL_MAX    16.5f

#define  BAT_CHARGE_TIME_MAX   (float32_t)(5.0)

#define  BAT_CHARGE_TIME_CAL_K   (float32_t)((0.0f - BAT_CHARGE_TIME_MAX) / (BAT_CHARGE_VOL_MAX - BAT_CHARGE_VOL_MIN))
#define  BAT_CHARGE_TIME_CAL_B   (float32_t)(0.0f - BAT_CHARGE_VOL_MAX * BAT_CHARGE_TIME_CAL_K)


typedef struct
{
	float32_t  vbattery_now;
	float32_t  vbattery_bef;
	
	float32_t  isbus_now;
	float32_t  isbus_old;
	float32_t  isbus_diff;
	
	uint16_t   status;
	uint16_t   gpio_level;
	uint16_t   gpio_level_old;
	
	uint32_t   overtime_est;
	uint32_t   waittime_est;
	uint32_t   waittime_cnt;
	
	uint16_t   hold_cnt;
	
}STR_CHARGE;


extern STR_CHARGE batCharge;
extern uint16_t battery_status_check(STR_CHARGE *hdl, float32_t vbattery, float32_t isbus);

#endif


